/*
 * 百度在线网络技术（北京）有限公司拥有本软件版权2021并保留所有权利。
 * Copyright 2021, Baidu.com,Inc 2:Baidu Online Network Technology (Beijing) Co.,Ltd,
 * All rights reserved.
 */

package com.azdebugit.spring.beantest.cnblog.spring.valu;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.Environment;

import java.math.BigDecimal;

public class TestB {
    @Test
    public void test() {
        //创建容器
        ApplicationContext applicationContext = new AnnotationConfigApplicationContext(BeanConfig.class);
        //从容器中获取Bottle实例
        Bottle bottle = (Bottle) applicationContext.getBean("bottle");
        //控制台输出
        System.out.println(bottle.toString());
        //从容器中获取环境变量
        Environment environment = applicationContext.getEnvironment();
        String source = environment.getProperty("bottle.source");
        System.out.println("\n" + source);
        //关闭容器
        ((AnnotationConfigApplicationContext) applicationContext).registerShutdownHook();
    }

    @Test
    public void test11() {
        //创建容器
        BigDecimal a = new BigDecimal(121);
        BigDecimal b = new BigDecimal(111);

        //使用compareTo方法比较
        //注意：a、b均不能为null，否则会报空指针
        if (a.compareTo(b) > -1) {
            System.out.println("a大于b");
        }
    }
    @Test
    public void test12() {
        BigDecimal amt = new BigDecimal(1001);
        BigDecimal[] results = amt.divideAndRemainder(BigDecimal.valueOf(20));
        System.out.println(results[0]);
        System.out.println(results[1]);
    }

}
